using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataAccessLayer;
using Cryptography;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["category"] = "";
        Session["keyword"] = "";
        Session["type"] = "";
        Session["USER"] = "";
        Session["toDelete"] = "";
    }
    /*
    protected void loginHome_Authenticate(object sender, AuthenticateEventArgs e)
    {

    }
    protected void imgbtnGo_Click(object sender, ImageClickEventArgs e)
    {
        // Session["searchCategory"] = ddlCategory.SelectedIndex;
    }
    */
    protected void btnUserLogin_Click(object sender, EventArgs e)
    {
        Common c = new Common();
        Cryptography.Cryptography oCrypto = new Cryptography.Cryptography();
        string conn = c.fetchConnString();
        User rg = new User(conn);
        rg.EMAIL = txtUEmail.Text;
        rg.PASSWORD = oCrypto.EncryptTripleDES(txtUPassword.Text, "Medicopedia");
        bool y = rg.login();
        if (y)
        {
            Session["type"] = "user";
            Session["USER"] = txtUEmail.Text;
            Session["user name"] = txtUEmail.Text;
            Response.Redirect("UserProfile.aspx");
        }
        else
            lblErrorUser.Visible = true;
    }
    protected void btnDoctorLogin_Click(object sender, EventArgs e)
    {
        Common c = new Common();
        string conn = c.fetchConnString();
        Doctor drg = new Doctor(conn);
        drg.REGNO = Convert.ToInt32(txtDRegNo.Text);
        drg.PASSWORD = txtDPassword.Text;
        bool y = drg.login();
        if (y)
        {
            Session["type"] = "doctor";
            Response.Redirect("DoctorProfile.aspx");
        }
        else
            lblErrorDoc.Visible = true;
    }
    protected void lnkForgotPassword_Click(object sender, EventArgs e)
    {
        Response.Redirect("PasswordRetrieval.aspx");
    }
    protected void lnkSignUp_Click(object sender, EventArgs e)
    {
        Response.Redirect("SignUp.aspx");
    }
    protected void lnkSearch_Click(object sender, EventArgs e)
    {
        Response.Redirect("SearchResults.aspx");
    }
    protected void imgbtnGoKeyword_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //
    }
    protected void lnkAboutUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("AboutUs.aspx");
    }
    protected void lnkContactUs_Click(object sender, EventArgs e)
    {
        Response.Redirect("ContactUs.aspx");
    }
    protected void lnkFeedback_Click(object sender, EventArgs e)
    {
        Response.Redirect("Feedback.aspx");
    }
    protected void LinkButton5_Click(object sender, EventArgs e)
    {
        //
    }
}
